<!DOCTYPE html>
<html>
{include file="public/header" /}
<body>

<div class="layui-fluid" id="app">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card" >
                <!--<div class="layui-card-header">财务报表,提现管理</div>-->
                <div class="layui-card-body">
                    <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                        <ul class="layui-tab-title">
                            <li class="layui-this">车辆颜色</li>
                        </ul>
                        <div class="layui-tab-content" style="padding-left: 0px;padding-right: 0px">
                            <div class="layui-tab-item layui-show">
                                <div class="layadmin-trailer ">
                                    <table class="layui-table" lay-skin="line">
                                        <thead>
                                            <tr>
                                                <th>#ID</th>
                                                <th>名称</th>
                                                <th>颜色</th>
                                                <th>排序</th>
                                                <!--<th></th>-->
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <tr v-for="(item,index) in items" :data_id="item.id">
                                                <td>{{item.id}}</td>
                                                <td>{{item.color}}</td>
                                                <td>{{item.assic}}</td>
                                                <td>{{item.sort}}</td>
                                                <!--<td>
                                                    <div class="layui-btn-group">
                                                        <button class="layui-btn layui-btn-sm layui-btn-primary" :data_id="item.id" :data_index="index">操作1</button>
                                                        <button class="layui-btn layui-btn-sm layui-btn-primary" :data_id="item.id" :data_index="index">操作2</button>
                                                    </div>
                                                </td>-->
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                                <div id="demo7"></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    //vue对象
    var app = new Vue({
        el: '#app',
        data: {
            check: [],
            curr: 1,//当前页
            limit: 10,//当前页
            items: []
        }
    });

    //初始数据
    function init() {
        layer.load(2);
        $.get('/admin/color/index', {page: app.curr, limit: app.limit},
            function (res) {
                layer.closeAll();
                app.items = res.data;
            }
        );
    }

    function edit(that) {
        var data_id = $(that).attr('data_id');
        layer.open({
            type: 2,
            title: '编辑',
            shadeClose: true,
            shade: 0.8,
            area: ['700px', '500px'],
            content: "{:url('edit')}?id=" + data_id //iframe的url
        });
    }

    //获取批量IDS
    function getCheckBox() {
        var check = [];
        $.each($('input[type=checkbox]:checked.vue_index'), function () {
            check.push($(this).val());
        });
        return check;
    }


    function del(that) {
        var ids = getCheckBox();
        if (ids.length > 0) {
            var index = layer.confirm('确认继续执行？', {
                btn: ['确定', '取消'] //按钮
            }, function () {
                $.post('{:url("del")}', {ids: ids}, function (res) {
                    if (res.code == 1) {
                        layer.msg(res.msg, {icon: 1})
                        init();
                    }
                    layer.close(index);
                });
            }, function () {
                layer.close(index);
            });
        }
    }

    //按需引入layui模块
    layui.use(['laypage', 'layer','table','element'], function () {
        var laypage = layui.laypage
            , layer = layui.layer;
        var table = layui.table;
        var elemnet = layui.element;
        //完整功能
        laypage.render({
            elem: 'demo7'
            , count: "{$count}"
            , limits: [10, 20]
            , layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
            , jump: function (obj) {
                console.log(obj)
                app.curr = obj.curr;
                app.limit = obj.limit;
                init();
            }
        });
    });


</script>


</body>
</html>




